<template>
  <div class="tool">
    <div class="tool-title">
      <h2>工具</h2>
    </div>
    <div class="tool-content">
      <div class="tool-card" v-for="(item, index) in toolList" :key="index">
        <div class="image"><img :src="item.avatar"></div>
        <div class="chain-content">
          <div class="tool-content-title">
            <span>{{ item.title }}</span>
            <span style="right: 10px;">
              <a :href="item.fileInfo.storeUrl" target="_blank" style="margin-left: 30px;text-decoration: none;">
                <i class="iconfont icon-xiazai1"></i>
              </a>&nbsp;<span style="font-size: 10px">下载量{{ item.downloadNum }}</span>
            </span>
          </div>
          <div class="bottom clearfix">
            <div class="time">{{ item.summary }}</div>
          </div>
          <div class="tool-time">
            <i class="iconfont icon-shijian"></i>发布于{{ item.createTime }}
          </div>
        </div>
      </div>
    </div>
    <div class="pagination">
      <el-pagination background layout="prev, pager, next" :current-page="currentPage" :page-size="pageSize"
                     :total="total" @current-change="handleCurrentChange"></el-pagination>
    </div>
  </div>
</template>

<script>
import {listTool} from "@/api";

export default {
  name: 'tool',
  data() {
    return {
      toolList: [],
      pageSize: 10,
      currentPage: 1,
      total: 0
    }
  },
  mounted() {
    this.listTool();
  },
  methods: {
    listTool() {
      listTool({pageNum: this.currentPage, pageSize: this.pageSize}).then(res => {
        this.toolList = res.data.results;
        this.currentPage = res.data.pageNum;
        this.total = res.data.total;
      })
    },
    handleCurrentChange: function (currentPage) {
      this.currentPage = currentPage;
      this.listSource();
    }
  }
}
</script>

<style scoped lang="less">
.tool {
  margin: 20px 0;
  background-color: #fff;
  min-height: 830px;
}

.tool-title {
  height: 70px;
  line-height: 70px;
  margin-left: 20px;
}

.tool-content {
  display: flex;
  flex-wrap: wrap;
  margin: 0 20px 20px 20px;
}

.tool-card {
  width: 250px;
  height: 260px;
  margin: 10px 10px;
  border-radius: 10px;
  background-color: #f5f7fa;
}

.chain-content {
  margin-left: 20px;
}

.tool-content-title {
  margin: 5px 0;
}

.image img {
  width: 250px;
  height: 150px;
  border-top-left-radius: 10px;
  border-top-right-radius: 10px;
}

.time {
  font-size: 14px;
  color: #999;
}

.tool-time {
  font-size: 10px;
  margin: 10px 0;
}

.bottom {
  margin-top: 10px;
  line-height: 12px;
}

.pagination {
  text-align: center;
}
</style>

